<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="http://117.80.114.220:81/static/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="http://117.80.114.220:81/static/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset" sec:authorize="hasAuthority('sys:user:query')">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" lay-filter="data-search-form" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户姓名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="userName" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">用户编码</label>
                            <div class="layui-input-inline">
                                <input type="text" name="userCode" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline" id="dateTime">
                            <div class="layui-input-inline">
                                <input type="text" autocomplete="off" name="start" id="startDateTime" class="layui-input" placeholder="开始日期">
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline">
                                <input type="text" autocomplete="off" name="end" id="endDateTime" class="layui-input" placeholder="结束日期">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-clear-btn"><i class="layui-icon"></i> 重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <table class="layui-hide" id="userLoginId" lay-filter="userTableFilter"></table>
    </div>
</div>
<script src="http://117.80.114.220:81/static/lib/layui/layui.js" charset="utf-8"></script>
<script src="http://117.80.114.220:81/static/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="http://117.80.114.220:81/static/js/my.js"></script>
<script>
    layui.use(['form', 'table','laydate'], function () {
        var $ = layui.jquery,
            form = layui.form,
            baseURL = layui.baseUrl,
            table = layui.table,
            laydate = layui.laydate;

        //日期范围
        laydate.render({
            elem: '#dateTime'
            //设置开始日期、日期日期的 input 选择器
            //数组格式为 2.6.6 开始新增，之前版本直接配置 true 或任意分割字符即可
            ,range: ['#startDateTime', '#endDateTime']
            ,type: 'datetime'
        });

        table.render({
            elem: '#userLoginId',
            url: baseURL + '/sys-active/list',
            cols: [
                [
                {field: 'userId', width: 80, title: 'ID'},
                {field: 'userName', minWidth: 100, title: '用户名'},
                {field: 'userCode', minWidth: 100, title: '用户编码'},
                {field: 'dateTime', minWidth: 100, title: '最后登录时间'},
                {field: 'ip', minWidth: 100, title: '用户ip'},
                {field: 'address', minWidth: 100, title: '用户地址'}
            ]
            ],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'line'
        });
        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            //执行搜索重载
            table.reload('userLoginId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });
        // 监听重置操作
        form.on('submit(data-clear-btn)', function (data) {
            form.val('data-search-form',{userName:"",userCode:"",mobile:"",email:""});
            //执行搜索重载
            table.reload('userLoginId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: {}
                }
            }, 'data');
            return false;
        });
    });
</script>
</body>
</html>
